#coding=UTF-8 
import sys  
reload(sys)  
sys.setdefaultencoding('utf8')
from chinacQA.Static import testEnvtConf
from chinacQA.TestCase import TestCase
from chinacQA.TestLink_TestCase import assertBool
from chinacQA.TestLink_TestCase import getConfigure_ENG
from chinacQA.TestLink_TestCase import setConfigure_ENG

from chinacQA.TestLink_TestCase import waitMoment
from template.NeoCUUI_ENG import *

import random

CN_Version = True

def Login(user, pw):
    global CN_Version
    idusername.text=user
    idpassword.text=pw
    if (loginBtn.text == "登录"):
        CN_Version = True
    else:
        CN_Version = False

    if(CN_Version == False and testEnvtConf.Language == "English (en)") or (CN_Version == True and testEnvtConf.Language.decode("gb2312") == "简体中文 (zh-cn)"):
        needChange = False
    else:
        needChange = True
    loginBtn.click()
    
    print "needChange: ",needChange
    if(needChange):
        STEP_ChangeLanguage()
        logonOut()
    else:
        logonOut_CN()
        

def STEP_AdminLoginAndChangeLanguage():
    Login(testEnvtConf.AdminName, testEnvtConf.AdminPassword)
    
def STEP_ChangeLanguage():
    AdminRole.click()
    LanguageCN.click()
    idlanguage.select(text=testEnvtConf.Language)
    btnsubmit.click()
    waitMoment(5)

#简体中文 (zh-cn)
#English (en)
def logonOut():
    adminrole.click()
    waitMoment(3)
    loginout.click()

def logonOut_CN():
    AdminRole.click()
    waitMoment(3)
    logout_CN.click()

TC_100_NeoCU_Language  = TestCase("Neocu change Language")
TC_100_NeoCU_Language.AddStep(STEP_AdminLoginAndChangeLanguage)

if __name__ == "__main__":
    TC_100_NeoCU_Language.run()
